package main

import (
	"log"
	"time"
)

func main() {
	chan1 := make(chan int)
	go func() {
		for i := 0; i < 5; i++ {
			log.Println("sub goroutine i=:", i)
			chan1 <- i
		}

	}()

	time.Sleep(time.Second)
	for i := 0; i < 5; i++ {
		num := <-chan1
		log.Println("main goroutine i=:", num)
	}

}
